//========encoding:utf-8=========
/*
 * @describe:  三目运算符
 * @author:mhao
 * @copyright:chinasoft.cn
 * @date:2020年3月17日   下午7:53:11
 */
package edu.chinasoft.handle;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.junit.runner.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller(value="userHandler")
public class UserHandler {
	private Logger logger = LoggerFactory.getLogger(UserHandler.class);
	@RequestMapping(value="/usercontrol.do",method= {RequestMethod.GET,RequestMethod.POST})
	public void method01(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		logger.info("UserHandler>>>method01 start ……");
		String userName = request.getParameter("user_name");
		String userPassword = request.getParameter("user_password");
		logger.info("用户名："+userName+",密码："+userPassword+"");
		//把数据保存到request容器
		request.setAttribute("key01", userName);
		request.setAttribute("key01", userPassword);
		//请求转发
		request.getRequestDispatcher("/loginsuccess.jsp").forward(request, response);
		logger.info("UserHandler>>>method01 end ……");
	}
	@RequestMapping(value="/usercontrol02.do",method= {RequestMethod.POST})
	public ModelAndView method02(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		logger.info("UserHandler>>>method01 start ……");
		String userName = request.getParameter("user_name");
		String userPassword = request.getParameter("user_password");
		logger.info("用户名："+userName+",密码："+userPassword+"");
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("key01", userName);
		modelAndView.addObject("key02", userPassword);
		modelAndView.setViewName("/loginsuccess.jsp");
		logger.info("UserHandler>>>method01 end ……");
		return modelAndView;
	}
	

}
